package com.game.commons.configuration.transformers;

import java.lang.reflect.Field;
import java.util.regex.Pattern;

import com.game.commons.configuration.PropertyTransformer;
import com.game.commons.configuration.TransformationException;


/**
 * 
 * @author 杜祥
 * @create 2013-6-29
 */
@SuppressWarnings("rawtypes")
public class PatternTransformer implements PropertyTransformer
{

	public static final PatternTransformer	SHARED_INSTANCE	= new PatternTransformer();


	
	@Override
	public Pattern transform(String value, Field field) throws TransformationException
	{
		try
		{
			return Pattern.compile(value);
		}
		catch(Exception e)
		{
			throw new TransformationException("Not valid RegExp: " + value, e);
		}
	}
}
